package com.atguigu.ssyx.common.auth;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import javax.annotation.Resource;

@Configuration
@Slf4j
public class LoginMvcConfigurerAdapter extends WebMvcConfigurerAdapter {


    @Resource
    private RedisTemplate redisTemplate;

    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new UserLoginInterceptor(redisTemplate)).addPathPatterns("/api/**")
                .excludePathPatterns("/api/user/weixin/wxLogin/*");;
        log.info("拦截器已加载");
        super.addInterceptors(registry);
    }
}
